﻿#pragma once 
class EulerEquation;
class IsoVortex;

#include <vtkm/Matrix.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/exec/ParametricCoordinates.h>
#include <vtkm/worklet/WorkletCellNeighborhood.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include "Types.h"

namespace Loops
{
/// @brief 采用CRTP抽象初始条件的基类，子类实现`ComputeValue`接口
/// @tparam Derived
//template<typename Derived>
struct WorkletInitCondition : vtkm::worklet::WorkletVisitCellsWithPoints
{
  using ControlSignature = void(CellSetIn, FieldOut, FieldInPoint, ExecObject eq);
  using ExecutionSignature = void(CellShape, _2, _3, _4);

  using ValueType = Vec<FloatDefault, 5>;

  template<typename CellShapeTag, typename VType, typename PType, typename ContextType>
  VTKM_EXEC void operator()(const CellShapeTag& shape,
                            VType& value,
                            const PType& pts,
                            ContextType& eq) const
  {
    vtkm::Vec3f lpoint;
    vtkm::exec::ParametricCoordinatesCenter(pts.GetNumberOfComponents(), shape, lpoint);
    typename PType::ComponentType wpoint;
    vtkm::exec::ParametricCoordinatesToWorldCoordinates(pts, lpoint, shape, wpoint);
    value = eq.InitialCondition(wpoint);
  }
};

void InitialConditionPassFlow(EulerEquation& eq);
void InitialConditionIsoVortex(IsoVortex& eq);
}